package com.chexiehui.jc.download;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class SaveImageToLocalFIle {

    //保存bitmap到fileName，文件名为bitmapName. 保存到相册图片
    public static boolean saveBitmap(String filePath, String bitmapName, Bitmap bitmap){
        FileOutputStream outputStream=null;
        try{

            File file = new File(filePath, bitmapName);
            if (!file.exists())file.createNewFile();
            //打印文件路径名


            outputStream = new FileOutputStream(file);
            // 将图像写到流中
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
            outputStream.flush();
            outputStream.close();
            return true;
        }catch (IOException e){
            e.printStackTrace();
        }
        return false;
    }




}
